<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link href="__ROOT__/Public/admin/css/style.css" rel="stylesheet">
<link href="__ROOT__/Public/admin/css/font-awesome.min.css" rel="stylesheet">
<link href="__ROOT__/Public/plugin/select2/select2.css" rel="stylesheet">
<script src="__ROOT__/Public/js/jquery.min.js"></script>
<script src="__ROOT__/Public/admin/laydate/laydate.js"></script>

<title>用户组列表</title>
</head>
<body>
	<div id="show">
		<div class="breadNav">
			<ul class="breadNavBar">
				<li><i class="icon-home"></i></li>
				<li><a href="#">首页</a></li>
				<li>&gt;</li>
				<li><a href="#">用户组列表</a></li>
				<li>&gt;</li>
				<li><a href="#" class="active">{$title}</a></li>
			</ul>
		</div>
		<div style="clear:both;"></div>
		<div class="filter">
			<div class="form-group" style="float:left">
		       <a href="__ROOT__/Admin/AuthManage/GroupList" class="btn btn-primary btn-lg" id="backBtn"><i class="icon-reply"></i>&nbsp;返回</a>
			</div>
		</div>
		<div style="clear:both;"></div>
	<div class="update-form">
		<form action="{:U()}" method="post" class="form-inline">
			<foreach name="result" item="v">
				<div class="row">
					<div class="form-group form-group-sm">
						<label class="checkbox-inline" style="font-weight:bold;">
							<input type="checkbox" name="rules[]" value="{$v.id}" data-control <eq name="v.check" value="1">checked</eq> />{$v.title}
						</label>
					</div>
				</div>
					<div class="row" style="padding-left:20px;">
						<div class="form-group form-group-sm">
				<foreach name="v.child" item="v1">
							<label class="checkbox-inline">
								<input type="checkbox" name="rules[]" data-bind="{$v.id}" value="{$v1.id}"  <eq name="v1.check" value="1">checked</eq> /> {$v1.title}
							</label>
				</foreach>
						</div>
					</div>
			</foreach>
			<div class="row">
				<div class="form-group form-group-sm">
					<button type="submit" class="btn btn-primary btn-sm">
					     <input type='hidden' name='groupid' value='{$groupid}'></input>
						<span>提交</span>
					</button>
				</div>
			</div>
		</form>
	</div>

<script type="text/javascript">
	$('form').on('change',':checkbox[data-bind]',function(){
		var self=$(this);
		var f=$(':checkbox[value='+self.attr('data-bind')+']');
		var sChecked=self.is(':checked');
		var fChecked=f.is(':checked');
		if(sChecked){
			if(!fChecked) f.prop('checked',true);
		}else{
			var bros=self.parents('.row').find(':checkbox[value!='+self.val()+']');
			var flag=false;
			for(var i=0;i<bros.length;i++){
				if(bros.eq(i).is(':checked')) flag=true;
			}
			f.prop('checked',flag);
		}
	});
	$('form').on('change',':checkbox[data-control]',function(){
		var self=$(this);
		var sChecked=self.is(':checked');
		var c=$(':checkbox[data-bind='+self.val()+']');
		for(var i=0;i<c.length;i++){
			c.eq(i).prop('checked',sChecked);
		}

	});
</script>



</body>
</html>